<!DOCTYPE html>
<html ng-app="myApp" ng-controller="FaultsController" ng-init="getFaults()">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>维修项目</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="../css/animate.css" rel="stylesheet">
    <link href="../css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">

    <div class="wrapper wrapper-content animated fadeInUp">
        <div class="row">
            <div class="col-sm-12">

                <div class="ibox">
                    <div class="ibox-title">
                        <h5>所有维修项目</h5>
                        <div class="ibox-tools">
                            <a href="form_wizard2.html" class="btn btn-primary btn-xs">创建新的维修项目</a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row m-b-sm m-t-sm">
                            <div class="col-md-1">
                                <button type="button" id="loading-example-btn" class="btn btn-white btn-sm"><i class="fa fa-refresh"></i> 刷新</button>
                            </div>
                            <div class="col-md-11">
                                <div class="input-group">
                                    <input ng-keyup="mykey($event)" type="text" placeholder="请输入故障名称" class="input-sm form-control" ng-model="find.title"> <span class="input-group-btn">
                                        <button type="button" id="search-btn" class="btn btn-sm btn-primary" ng-click="findFault()"> 搜索</button> </span>
                                </div>
                            </div>
                        </div>

                        <div class="project-list">

                            <table class="table table-hover">
                                <tbody>
                                    <tr ng-repeat="fault in allFaults[p_current-1]">
                                        <td class="project-status">
                                            <span class="label label-primary">进行中
                                        </td>
                                        <td class="project-title">
                                            <a ng-click="setFaultId(fault._id)" ng-bind="fault.title"></a>
                                            <br/>
                                             <small>发生于</small>  <small ng-bind="fault.occur_date.substr(0,10)"></small>
                                        </td>
                                        <td class="project-completion">
                                                <small>当前进度： {{ fault.progress * 100 }}%</small>
                                                <div class="progress progress-mini">
                                                    <div style="width: {{ fault.progress *100 }}%;" class="progress-bar"></div>
                                                </div>
                                        </td>
                                        <td class="project-people">
                                            <!--<a href="projects.html"><img alt="image" class="img-circle" src="img/a3.jpg"></a>-->
                                            <!--<a href="projects.html"><img alt="image" class="img-circle" src="img/a1.jpg"></a>-->
                                            <!--<a href="projects.html"><img alt="image" class="img-circle" src="img/a2.jpg"></a>-->
                                            <!--<a href="projects.html"><img alt="image" class="img-circle" src="img/a4.jpg"></a>-->
                                            <!--<a href="projects.html"><img alt="image" class="img-circle" src="img/a5.jpg"></a>-->
                                            <span class="badge badge-primary" ng-show="fault.level == '较为严重' ">{{ fault.level }}</span>
                                            <span class="badge badge-danger" ng-show="fault.level == '严重' ">{{ fault.level }}</span>
                                            <span class="badge badge-danger" ng-show="fault.level == '非常严重' ">{{ fault.level }}</span>
                                            <span class="badge badge-primary" ng-show="fault.level == '轻微' ">{{ fault.level }}</span>
                                            </div>
                                        </td>
                                        <td class="project-actions">
                                            <!--<a href="project_detail.html#/{{ fault._id }}" class="btn btn-white btn-sm" ng-click="test()"><i class="fa fa-folder"></i> 查看 </a>-->
                                            <a  class="btn btn-white btn-sm" ng-click="setFaultId(fault._id)"><i class="fa fa-folder"></i> 查看 </a>
                                            <a  class="btn btn-white btn-sm" ng-click="editFault(fault._id)"><i class="fa fa-pencil" ></i> 编辑 </a>
                                            <a   class="btn btn-white btn-sm" ng-click="uploadFaultImage(fault._id)" ><i class="fa fa-file-image-o" ></i> 上传 </a>
                                            <a  class="btn btn-white btn-sm" ng-click="setFaultIdToDelete(fault._id,$index)" data-toggle="modal" data-target="#myModal"><i class="fa fa-remove"></i> 删除 </a>
                                        </td>
                                    </tr>




                        </tbody>
                                </table>




                        <ul class="pagination" style="margin: 0px;">
                            <li ng-class="{true:'disabled'}[p_current==1]"><a ng-click="p_index()">首页</a></li>
                            <li ng-class="{true:'active'}[p_current==page]" ng-repeat="page in pages"><a  ng-click="load_page(page)">{{ page }}</a></li>
                            <li ng-class="{true:'disabled'}[p_current==p_all_page]"><a ng-click="p_last()">尾页</a></li>
                        </ul>
                        <span style="vertical-align: 12px;">&nbsp;&nbsp;目前共：{{count}} 个维修项目</span>





                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">确定要删除该故障项目({{ toDeleteFault.title }})吗？</h4>
                </div>
                <div class="modal-body">

                    <dl class="dl-horizontal" style="text-align: center">

                        <dt>所在工厂车间：</dt>
                        <dd ng-bind="toDeleteFault.factory"></dd>
                        <dt>机床型号：</dt>
                        <dd ng-bind="toDeleteFault.machine_type"></dd>
                        <dt>故障部位：</dt>
                        <dd ng-bind="toDeleteFault.location"></dd>
                        <dt>故障等级：</dt>
                        <dd><span class="badge badge-primary" ng-show="toDeleteFault.level == '较为严重' " ng-bind="toDeleteFault.level"></span>
                            <span class="badge badge-danger" ng-show="toDeleteFault.level == '严重' " ng-bind="toDeleteFault.level"></span>
                            <span class="badge badge-danger" ng-show="toDeleteFault.level == '非常严重' " ng-bind="toDeleteFault.level"></span>
                            <span class="badge badge-primary" ng-show="toDeleteFault.level == '轻微' " ng-bind="toDeleteFault.level"></span>
                        </dd>

                    </dl>

                      </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" ng-click="removeFault(toDeleteFault._id)" data-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>




    <!-- 全局js -->
    <script src="../js/jquery.min.js?v=2.1.4"></script>
    <script src="../js/bootstrap.min.js?v=3.3.6"></script>


    <!-- 自定义js -->
    <script src="../js/content.js?v=1.0.0"></script>



    <!--angular-->
    <script src="//cdn.bootcss.com/angular.js/1.5.8/angular.js"></script>
    <script src="//cdn.bootcss.com/angular.js/1.5.8/angular-cookies.js"></script>



    <!--<script src="//cdn.bootcss.com/angular.js/1.5.8/angular-route.js"></script>-->
    <!--<script src="/controllers/client.js"></script>-->
    <script type="text/javascript" src="../controllers/projects.js"></script>


    <script>
        $(document).ready(function(){

            $('#loading-example-btn').click(function () {
                btn = $(this);
                simpleLoad(btn, true)

                // Ajax example
//                $.ajax().always(function () {
//                    simpleLoad($(this), false)
//                });

                simpleLoad(btn, false)
            });
        });

        function simpleLoad(btn, state) {
            if (state) {
                btn.children().addClass('fa-spin');
                btn.contents().last().replaceWith(" Loading");
            } else {
                setTimeout(function () {
                    btn.children().removeClass('fa-spin');
                    btn.contents().last().replaceWith(" Refresh");
                }, 2000);
            }
        }
    </script>

    

    </body>
</html>
